<?php
namespace app\index\controller;
use think\Session;
use think\Controller;
use think\Db;
class Index extends Controller
{
    public function index()
    {
        if (session("login")==1) {
        	$dc=db("doctor")->count();
        	$bc=db("clinic")->count()-1;
        	$cc=db("case")->count();
        	$uc=db("customer")->count();
        	$ncc=db("case")->whereTime('date', 'today')->count();
        	$nuc=db("customer")->whereTime('firstdate', 'today')->count();
        	$result=Db::query("SELECT a.appo_id,a.name as 'c_name',d.name as 'd_name',c.name as 'md_name',ask,a.tel,state,a.time,a.state FROM appointment a left join doctor d left join clinic c on d.clinic=c.id on a.doctor_id=d.id where TO_DAYS(a.time)=TO_DAYS(NOW()) and a.doctor_id=".session("uid"));
        	$revisit=Db::query("SELECT * from customer where TO_DAYS(lastdate)=TO_DAYS(NOW()) and doctor=".session("uid"));
        	$this->assign("data",array(
        			"nu"=>$nuc,
        			"nc"=>$ncc,
        			"u"=>$uc,
        			"c"=>$cc,
        			"d"=>$dc,
        			"b"=>$bc,
        		));
        	$this->assign("arr",$result);	
        	$this->assign("revisit",$revisit);	
            return view('index');
        }else return redirect('/User/Login');;
    }
}


